<template>
	<div>
		<div class="Abox" v-loading="loading">
			<div class="content">
				<Info
					ref="Info"
					v-model="infoData"
					v-bind="querys"
					state="readonly"></Info>
				<Contract
					ref="Contract"
					v-model="infoData"
					v-bind="querys"
					:showHistory="false"
					state="readonly"></Contract>
				<Footer
					ref="Footer"
					v-model="infoData"
					v-bind="querys"
					state="readonly"></Footer>
				<!-- <el-button -->
				<!-- class="orderChangeHistory" -->
				<!-- type="primary" -->
				<!-- @click="toOrderChangeHistory"> -->
				<!-- 查看变更历史记录 -->
				<!-- </el-button> -->
			</div>
			<div>
				<A-FlowRecord :id="processId"></A-FlowRecord>
			</div>
		</div>
		<div class="handle">
			<el-button @click="back">返回</el-button>
		</div>
	</div>
</template>

<script>
	import * as apis from '@/api/order/minOrder/contractChange/api.js';
	import Info from '../chunk/info/index.vue';
	import Contract from '../chunk/contract/index.vue';
	import Footer from '../chunk/adjust/footer/index.vue';
	export default {
		name: 'MinContractChangePreview',
		props: {
			state: {
				required: false,
			},
		},
		components: { Info, Contract, Footer },
		data() {
			return {
				infoData: {
					previousData: {},
					subsequentData: {},
				},
				querys: {},
				loading: false,
				dictList: {
					changeType: [
						{
							label: '出租方',
							value: '1',
						},
						{
							label: '承租方',
							value: '2',
						},
						{
							label: '租赁期限',
							value: '4',
						},
						{
							label: '车辆',
							value: '8',
						},
						{
							label: '租金调整',
							value: '16',
						},
						{
							label: '租金',
							value: '32',
						},
						{
							label: '保险',
							value: '64',
						},
						{
							label: '维保',
							value: '128',
						},
						{
							label: '替车',
							value: '256',
						},
						{
							label: '加装',
							value: '512',
						},
						{
							label: '其他费用',
							value: '1024',
						},
					],
				},
			};
		},

		computed: {
			processId() {
				return this.infoData.processId;
			},
		},
		created() {
			this.querys = this.$route.query ?? {};
			this.getOrderCarChangeInfo();
		},
		mounted() {},
		methods: {
			getOrderCarChangeInfo() {
				if (this.Empty(this.querys.orderCarChangeId)) {
					this.$message.error('缺少参数 子订单改变id');
					return;
				}
				this.loading = true;
				apis.OrderCarChangeInfo(this.querys.orderCarChangeId)
					.then(res => {
						if (res.code == 200) {
							// let changeType = [];
							// this.dictList.changeType.map(item => {
							// 	if (
							// 		(res.data.changeType & (item.value * 1)) >
							// 		0
							// 	) {
							// 		changeType.push(item.value);
							// 	}
							// });
							// res.data.changeType = changeType;
							this.infoData = res.data ?? {};
							console.log();

							this._onload();
						}
					})
					.finally(() => {
						this.loading = false;
					});
			},
			toOrderChangeHistory() {
				this._toPage({
					name: 'MinOrderChangeHistory',
					query: {
						orderCarId: this.querys.orderCarId,
					},
				});
			},
			back() {
				this._closeCurrentPage();

				if (this.notEmpty(this.$route.query.from)) {
					this._toPage({
						name: this.$route.query.from,
						query: this.$route.query,
					});
				}
			},
		},
	};
</script>

<style lang="scss" scoped>
	.Abox {
		display: flex;
		.content {
			flex: 1;
			min-width: 0;
		}
	}
	.orderChangeHistory {
		position: fixed;
		bottom: calc(100vh - 150px);
		right: 40px;
		cursor: pointer;
		transition: all 0.3s;
	}
	.handle {
		height: 60px;
		display: flex;
		justify-content: flex-end;
		align-items: center;
		background-color: #fff;
		margin: 20px;
		padding: 0 20px;
		border-radius: 8px;
		box-sizing: border-box;
	}
</style>
